package tblModelGerecht;

import java.util.ArrayList;
import javax.swing.event.TableModelListener;
import javax.swing.table.TableModel;
import pnlBeheer.PnlGDBeheer;
import daoDataFactory.DaoFactory;
import domijn.Gerecht;


public class TMGerecht implements TableModel {
	
	
	@SuppressWarnings("unused")
	private PnlGDBeheer pnlGDBeheer;
	private String []names = {"Menu","Categorie","Nummer","Naam","Prijs"};
	private ArrayList<Gerecht> algerecht;
	private Gerecht g;

	public TMGerecht(PnlGDBeheer pnlGDBeheer) {
		this.pnlGDBeheer = pnlGDBeheer;
		algerecht = DaoFactory.getwokapplicatie().getDaoIGerecht().loadall();
		System.out.println(g);        
    }

	@Override
	public int getRowCount() {
		return algerecht.size();
	}

	@Override
	public int getColumnCount() {
		return names.length;
	}
	
	@Override
	public String getColumnName(int column) {
		return names[column];
	}

	@Override
	public Class<Gerecht> getColumnClass(int column) {
		return Gerecht.class;
	}

	@Override
	public boolean isCellEditable(int arg0, int arg1) {
		return false;
	}
	
	@Override
	public Object getValueAt(int rowIndex, int columnIndex) {
		g = algerecht.get(rowIndex);
		 switch (columnIndex){
         case 0:
        	 return g.getMenu();
         case 1: 
        	 return g.getCat();
         case 2:
             return g.getGrNewNumber();
         case 3:
        	 return g.getGrName();
         case 4:
        	 return g.getGrPrice();
            }
        return g;
        }
	
	@Override
	public void setValueAt(Object arg0, int arg1, int arg2) {
	}
	
	@Override
	public void addTableModelListener(TableModelListener arg0) {
	}
	
	@Override
	public void removeTableModelListener(TableModelListener arg0) {
	}

    public void addGerecht(final Gerecht gerecht) {
        algerecht.add(gerecht);
    }

}
